#include<cstdio>//E
#include<cstring>

char M[110][110];
bool visit[110][110];

int x_turn[9]={0,0,0,1,1,1,-1,-1,-1};
int y_turn[9]={0,1,-1,0,1,-1,0,1,-1};

int n,m,ans;

void init()
{
	ans=0;
	memset(visit,false,sizeof(visit));
	return ;
}

void DFS(int x,int y)
{
	for(int i=1;i<=8;++i)
	{
		if(x+x_turn[i]<=0||x+x_turn[i]>n||y+y_turn[i]<=0||y+y_turn[i]>m)continue;
		if(M[x+x_turn[i]][y+y_turn[i]]=='@'&&visit[x+x_turn[i]][y+y_turn[i]]==false)
		{
			visit[x+x_turn[i]][y+y_turn[i]]=true;
			DFS(x+x_turn[i],y+y_turn[i]);
		}
	}
	return ;
}

int main()
{
	while(true)
	{
		scanf("%d%d\n",&n,&m);
		if(!n)break;
		init();
		for(int i=1;i<=n;++i)
		{
			for(int j=1;j<=m;++j)
			{
				scanf("%c",&M[i][j]);
			}
			scanf("\n");
		}
		for(int i=1;i<=n;++i)
		{
			for(int j=1;j<=m;++j)
			{
				if(M[i][j]=='@'&&visit[i][j]==false)
				{
					ans++;
					DFS(i,j);
				}
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}
